<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCartsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('carts', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('user_id');
            $table->bigInteger('good_id')->comment('商品ID，取自goods表');
            $table->smallInteger('number')->comment('商品的购买数量，在购物车时，商品实际库存不减少');
            $table->decimal('price')->comment('商品加入购物车价格');
            $table->bigInteger('parent')->nullable()->comment('父商品id，如果有该值则代表改商品为父商品的赠品');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('carts');
    }
}
